package com.lwj.liwanjia.view.activity.logistics;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.adapter.LogisticsAdater;
import com.lwj.liwanjia.base.BaseActivity;
import com.lwj.liwanjia.utils.GlideImageLoader;
import com.superrecycleview.superlibrary.recycleview.SuperRecyclerView;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 物流快递
 */
public class LogisticsActivity extends BaseActivity {


    @BindView(R.id.tv_left)
    TextView tvLeft;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.rl_fuwuzhan)
    SuperRecyclerView rlFuwuzhan;

    private List<String> imageList = new ArrayList<>();
    private LogisticsAdater adater;
    private ViewHolder holder;
    private List<String> list = new ArrayList<>();

    @Override
    protected void initView() {
        tvLeft.setVisibility(View.VISIBLE);
        tvTitle.setText("物流快递");
        LinearLayoutManager manager = new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        rlFuwuzhan.setLayoutManager(manager);
        rlFuwuzhan.setRefreshEnabled(false);
        rlFuwuzhan.setLoadMoreEnabled(false);
        imageList.add("http://101.132.69.99/images/1.jpg");
        imageList.add("http://101.132.69.99/images/2.jpg");
        imageList.add("http://101.132.69.99/images/3.jpg");
        adater = new LogisticsAdater(this, imageList);
        addView();
        rlFuwuzhan.setAdapter(adater);
        //附近没有服务站
        holder.tvFujing.setVisibility(View.VISIBLE);
        holder.banner.setImages(imageList)
                .setImageLoader(new GlideImageLoader())
                .setBannerStyle(BannerConfig.CIRCLE_INDICATOR)
                .setDelayTime(4000)
                .start();
        listener();
    }

    private void listener() {
        //快递记录
        holder.tvJilu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(LogisticsActivity.this, KuaidiRecordActivity.class));
            }
        });
        //快递上门
        holder.tvShangmen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(LogisticsActivity.this, CallKuaidiActivity.class).putExtra("type", "快递上门"));
            }
        });
        //驿站寄件
        holder.tvYizhan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(LogisticsActivity.this, CallKuaidiActivity.class).putExtra("type", "驿站寄件"));
            }
        });
    }

    private void addView() {
        View headView = LayoutInflater.from(this).inflate(R.layout.logistics_head_layout, null);
        holder = new ViewHolder(headView);
        adater.addHeaderView(headView);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_logistics;
    }


    @OnClick({R.id.tv_left})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_left://返回
                finish();
                break;
        }
    }

    static class ViewHolder {
        @BindView(R.id.banner)
        Banner banner;
        @BindView(R.id.tv_jilu)
        TextView tvJilu;
        @BindView(R.id.tv_shangmen)
        TextView tvShangmen;
        @BindView(R.id.tv_yizhan)
        TextView tvYizhan;
        @BindView(R.id.tv_fujing)
        TextView tvFujing;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
